package oop.java0406;
/**
 * 对于除数a和被除数b (b=0)，
 * <p>
 * (1)如果二者均为int型(long也是int型)，结果会抛出异常：java.lang.ArithmeticException: / by zero
 * <p>
 * (2)如果其中有一个为double或者float型，结果则是Infinity
 */

import java.util.InputMismatchException;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("输入总课时，课程数：");
        try {
            int total = in.nextInt();
            int course = in.nextInt();

            int avg = total / course;
            method(total);
            System.out.println("平均课时数：" + avg);

            //avgCourse(total,course);
        } catch (InputMismatchException e) {
            System.err.print(e);
        } catch (ArithmeticException e) {
            System.err.println(e);
        } catch (Myexception e) {
            System.out.println("Exception:课程数太少");
        }


    }

    public static void method(int course) throws Myexception {
        if (course < 100) {
            throw new Myexception();
        }
    }
}
